{template modoer_header}
<div id="body">
<div class="myhead"></div>
<div class="mymiddle">
    <div class="myleft">
        <!--{template 'menu','member','member'}-->
    </div>
    <div class="myright">
        <div class="myright_top"></div>
        <div class="myright_middle">
            <h3>兑换礼品</h3>
            <div class="mainrail">
                <form method="post" name="myform"{if $lid} action="{url exchange/member/ac/$ac/lid/$lid/rand/$_G[random]}"{else} action="{url exchange/member/ac/$ac/rand/$_G[random]}"{/if}>
                <input type="hidden" name="giftid" value="$giftid" />
                <!--{if $gift['pattern']==2}--><input type="hidden" name="lid" value="$lid" /><!--{/if}-->
                <!--{if $from}-->
                <input type="hidden" name="from" value="$from" />
                <!--{loop $gift['params'] $k=>$v}-->
                <input type="hidden" name="$k" value="$v" />
                <!--{/loop}-->
                <!--{/if}-->
                <table width="100%" cellspacing="0" cellpadding="0" class="maintable">
                    <tr>
                        <td align="right" width="80">礼品名称：</td>
                        <td width="*"><a href="{url exchange/gift/id/$gift[giftid]}" target="_blank">$gift[name]</a></td>
                        <td width="220" rowspan="5">
                            <img src="{URLROOT}/$gift[thumb]" />
                            <!--{if $address && $gift['sort'] != '2'}-->
                                <br /><br />
                                <select id="address" onchange="insert_address(this.value);">
                                    <option value=''>==选择收货地址==</option>
                                    {dbres $address $val}
                                    <option value="$val[name]||$val[addr]||$val[postcode]||$val[mobile]"{if $val[is_default]}default="Y"{/if}>$val[name]($val[mobile])</option>
                                    {/dbres}
                                </select>   
                            <!--{/if}-->
                        </td>
                    </tr>
                    <tr>
                        <td align="right">礼品单价：</td>
                        <td><span class="font_2">$gift[price]</span>&nbsp;{print:member point(point/$gift[pointtype])}<!--{if $gift[point]}--> 或者 <span class="font_2">$gift[point]</span>&nbsp;{print:member point(point/$gift[pointtype2])}<!--{/if}--><!--{if $gift[point3]}--> 或者 <span class="font_2">$gift[point3]</span>&nbsp;{print:member point(point/$gift[pointtype3])}+<span class="font_2">$gift[point4]</span>&nbsp;{print:member point(point/$gift[pointtype4])}<!--{/if}--></td>
                    </tr>
                    <tr>
                        <td align="right">我的{print:member point(point/$gift[pointtype])}：</td>
                        <td><span class="font_2">{print $user->$gift[pointtype]}</span>&nbsp;{print:member point(point/$gift[pointtype]/keyname/unit)}<!--{if $minfo[$gift[pointtype]]<$gift[price]}--> 您的{print:member point(point/$gift[pointtype])}不够支付本次订单，请使用其他积分支付。<!--{/if}--></td>
                    </tr>
                    <!--{if $gift[point]}-->
                    <tr>
                        <td align="right">我的{print:member point(point/$gift[pointtype2])}：</td>
                        <td><span class="font_2">{print $user->$gift[pointtype2]}</span>&nbsp;{print:member point(point/$gift[pointtype2]/keyname/unit)}<!--{if $minfo[$gift[pointtype2]]<$gift[point]}--> 您的{print:member point(point/$gift[pointtype2])}不够支付本次订单，请使用其他积分支付。<!--{/if}--></td>
                    </tr>
                    <!--{/if}-->
                    <!--{if $gift['pattern']!='2'}-->
                    <tr>
                        <td align="right"><span class="font_1">*</span>支付方式：</td>
                        <td><input type="radio" name="pay_style" id="pay_1" value="1" /><lable for="pay_1">$gift[price]{print:member point(point/$gift[pointtype])}<!--{if $gift[point]}--> <input type="radio" name="pay_style" id="pay_2" value="2" /><lable for="pay_2">$gift[point]{print:member point(point/$gift[pointtype2])}<!--{/if}--><!--{if $gift[point3]}--> <input type="radio" name="pay_style" id="pay_3" value="3" /><lable for="pay_3">$gift[point3]{print:member point(point/$gift[pointtype3])}+$gift[point4]{print:member point(point/$gift[pointtype4])}<!--{/if}--></td>
                    </tr>
                    <script type="text/javascript">
                        $(document).ready(function(){
                            if(!$('[name=pay_style]').attr('checked')) {
                                $('[name=pay_style]').get(0).checked = true;
                            }
                        });
                    </script>
                    <!--{/if}-->
                    <tr>
                        <td align="right"><span class="font_1">*</span>兑换数量：</td>
                        <td><input type="text" name="number" class="t_input" size="10" value="1"{if $_GET[pattern]==2} onfocus="this.blur()"{/if} />{if $_GET[pattern]==2} 抽奖模式禁止修改兑换数量。{/if}</td>
                    </tr>
					<!--{if $gift['sort']!='2'}-->
                    <tr>
                        <td align="right"><span class="font_1">*</span>联系人：</td>
                        <td><input type="text" name="linkman" class="t_input" size="30" /></td>
                    </tr>
                    <tr>
                        <td align="right"><span class="font_1">*</span>联系电话：</td>
                        <td><input type="text" name="contact" class="t_input" size="30" /></td>
                    </tr>
                    <tr>
                        <td align="right"><span class="font_1">*</span>邮编：</td>
                        <td><input type="text" name="postcode" class="t_input" size="10" /></td>
                    </tr>
                    <tr>
                        <td align="right"><span class="font_1">*</span>联系地址：</td>
                        <td><input type="text" name="address" class="t_input" size="40"  /></td>
                    </tr>
					<!--{/if}-->
                    <tr>
                        <td align="right" valign="top">备注说明：</td>
                        <td colspan="2"><textarea name="des" style="width:400px;height:100px;"></textarea></td>
                    </tr>
                    <!--{if $MOD[exchange_seccode]}-->
                    <tr>
                        <td align="right"><span class="font_1">*</span>验证码：</td>
                        <td><input type="text" name="seccode" onfocus="show_seccode();" class="t_input" validator="{'empty':'N','errmsg':'请填写验证码。'}" /> <div id="seccode"></div></td>
                    </tr>
                    <!--{/if}-->
                </table>
                <div class="text_center">
                    <input type="hidden" name="forward" value="{print get_forward()}" />
                    <input type="hidden" name="dosubmit" value="yes" />
                    <button type="submit" name="dosubmit" value="yes">提交兑换</button>
                </div>
                </form>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="mybottom"></div>
</div>
<script type="text/javascript">
window.onload = function() {
    auto_address();
}
function auto_address() {
    var sel = $('#address');
    if(!sel[0]) return;
    sel.find('option').each(function(i) {
        if($(this).attr('default')=='Y') {
            insert_address($(this).val());
        }
    });
}
function insert_address(value) {
    if(value=='') return;
    var addr = value.split('||');
    $('[name="linkman"]').val(addr[0]);
    $('[name="address"]').val(addr[1]);
    $('[name="postcode"]').val(addr[2]);
    $('[name="contact"]').val(addr[3]);
}
</script>
<!--{eval footer();}-->